<?php
/**
 * Enter description here ...
 * @author NgoAnhTu
 * @date 2013-10-13
 */
final class LanguageDAO extends DAO {
	
	private static $instance = null;
	
	/**
	 * LanguageDAO instance only
	 * @return LanguageDAO
	 */
	public static function getInstance() {
		if (self::$instance == null)
			self::$instance = new LanguageDAO("Language");
		return self::$instance;
	}
	
	/**
	 * Active many Languages
	 * @param string $codes
	 */
	public function active($codes) {
		$lang = new Language();
		$this->unsetProperties($lang);
		
		$sql = DAO::SQL_UPDATE;
		$this->addTable($sql);
		
		$lang->active = 0;
		$unactiveSql = $sql;
		$this->addCondition($unactiveSql, '');
		$this->addUpdateValues($unactiveSql, $lang);
		$this->exec($unactiveSql);
		
		$lang->active = 1;
		$this->addCondition($sql, "Code IN($codes)");
		$this->addUpdateValues($sql, $lang);
		$this->exec($sql);
	}
}
?>